import time

from vidgear.gears import CamGear, StreamGear
import cv2


stream = CamGear(source="rtmp://139.155.181.21/live/Cam", logging=True).start()
while True:
    lastTime = time.time()
    frame = stream.read()
    if frame is None:
        break
    cv2.imshow('test', frame)
    nowTime = time.time()
    # if nowTime - lastTime != 0:
    #     print(f"FPS: {1 / (nowTime - lastTime)}")
    key = cv2.waitKey(1) & 0xFF
    if key == ord('q'):
        break
cv2.destroyAllWindows()
stream.stop()